Skip to content

Generate a CMake-time error if compiler+flags lacks deducing this support - #12

Merged
camio merged 4 commits into
bemanproject:mainfrom
camio:cmake-time-deducing-this-error
Oct 21, 2024
Merged

Generate a CMake-time error if compiler+flags lacks deducing this support#12
camio merged 4 commits into
bemanproject:mainfrom
camio:cmake-time-deducing-this-error

Conversation

@camio

@camio camio commented Oct 18, 2024

Copy link
Copy Markdown
Member

This improves the user experience when incompatible flags are used. It
also is a first step toward resolving #10.

…port

This improves the user experience when incompatible flags are used. It
also is a first step toward resolving bemanproject#10.
@camio
camio requested a review from steve-downey as a code owner October 18, 2024 17:20
camio added a commit to camio/iterator_interface26 that referenced this pull request Oct 18, 2024
Added a build option, BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS, that
switches between the deducing this implementation and that used by
stl_interfaces. It defaults to whether the compiler supports deducing this.

This element of configuration is placed in a generated config.hpp. This
was chosen, as opposed to using a define passed as a compiler flag, to
avoid ODR violations with larger projects with incoherent flag usage.

The `iterator_interface_access` struct was moved to its own header since
it is needed by both the deducing this and stl_interfaces implementations.
The stl_interfaces implementation was modifed to use this so it better
conforms to the paper.

Some cleanup is still needed before this gets merged in:

- There are optional26 remnants where stl_interfaces was brought
  in from.
- Documentation is needed to explain when the extra template parameter
  is required. BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS() should
  probably also be mentioned in that context.

The intent is to address these once the overall approach has
consensus.

Fixes bemanproject#10 and depends on bemanproject#12.
@neatudarius
neatudarius self-requested a review October 21, 2024 14:32
@camio

camio commented Oct 21, 2024

Copy link
Copy Markdown
Member Author

Weird, it looks like clang18 has deducing this support, but isn't advertising it with the __cpp_explicit_this_parameter define.

@camio

camio commented Oct 21, 2024

Copy link
Copy Markdown
Member Author

I added a workaround for it and filed a bug report. The build now succeeds on clang 18 and 14 and fails on clang 17 and gcc 13, which is expected.

@camio
camio merged commit 88ec881 into bemanproject:main Oct 21, 2024
@camio
camio deleted the cmake-time-deducing-this-error branch October 21, 2024 15:18
camio added a commit to camio/iterator_interface26 that referenced this pull request Oct 21, 2024
Added a build option, BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS, that
switches between the deducing this implementation and that used by
stl_interfaces. It defaults to whether the compiler supports deducing this.

This element of configuration is placed in a generated config.hpp. This
was chosen, as opposed to using a define passed as a compiler flag, to
avoid ODR violations with larger projects with incoherent flag usage.

The `iterator_interface_access` struct was moved to its own header since
it is needed by both the deducing this and stl_interfaces implementations.
The stl_interfaces implementation was modifed to use this so it better
conforms to the paper.

Some cleanup is still needed before this gets merged in:

- There are optional26 remnants where stl_interfaces was brought
  in from.
- Documentation is needed to explain when the extra template parameter
  is required. BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS() should
  probably also be mentioned in that context.

The intent is to address these once the overall approach has
consensus.

Fixes bemanproject#10 and depends on bemanproject#12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants